﻿using System;
using System.Collections.Generic;

namespace HigLabo.Net.Twitter
{
    /// <summary>
    /// 
    /// </summary>
    public class GetReverseGeoCodeCommand : TwitterCommand
    {
        private static readonly Double LatMaxValue = 90;
        private static readonly Double LatMinValue = -90;
        private static readonly Double LongMaxValue = 180;
        private static readonly Double LongMinValue = -180;
        private Double _Latitude = 0;
        private Double _Longitude = 0;
        /// <summary>
        /// 
        /// </summary>
        public Double Latitude
        {
            get { return _Latitude; }
            set
            {
                if (value < LatMinValue)
                {
                    value = LatMinValue;
                }
                if (value > LatMaxValue)
                {
                    value = LatMaxValue;
                }
                _Latitude = value;
            }
        }
        /// <summary>
        /// 
        /// </summary>
        public Double Longitude
        {
            get { return _Longitude; }
            set
            {
                if (value < LongMinValue)
                {
                    value = LongMinValue;
                }
                if (value > LongMaxValue)
                {
                    value = LongMaxValue;
                }
                _Longitude = value;
            }
        }
        /// <summary>
        /// 
        /// </summary>
        public String Accuracy { set; get; }
        /// <summary>
        /// must be one of: poi, neighborhood, city, admin or country.
        /// </summary>
        public String Granularity { set; get; }
        /// <summary>
        /// 
        /// </summary>
        public Int32 MaxResults { set; get; }
        /// <summary>
        /// 
        /// </summary>
        public String PlaceID { set; get; }
        /// <summary>
        /// 
        /// </summary>
        public String Callback { set; get; }

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        protected override IDictionary<String, String> CreateParameters()
        {
            Dictionary<String, String> d = new Dictionary<String, String>();
            d["lat"] = this.Latitude.ToString();
            d["long"] = this.Longitude.ToString();
            d["accuracy"] = this.Accuracy;
            d["granularity"] = this.Granularity;
            d["max_results"] = this.MaxResults.ToString();
            d["callback"] = this.Callback;
            return d;
        }
    }
}
